const path =require('path')

var htmlWebpackPlugin = require('html-webpack-plugin')

// 配置文件
module.exports = {
  entry: path.join(__dirname,'./src/main.js'), //入口文件
  output:{
      //node.js中__dirname变量获取当前模块文件所在目录的完整绝对路径 
      path:path.join(__dirname,'./dist'), //输出位置
      filename:'bundle.js' //输入文件
  },
  module:{
    rules: [
      { test: /\.css$/, use: ['style-loader','css-loader'] },//处理css的loader
      { test: /\.less$/, use: ['style-loader','css-loader','less-loader'] },//处理less文件的loader
      { test: /\.less$/, use: ['style-loader','css-loader','sass-loader'] },//处理sass文件的loader
      {test: /\.(png|jpg|gif|bmp|jpeg)$/,use:'url-loader?limit=10061&name=[hash:8]-[name].[ext]'},//处理图片
      {test: /\.(ttf|eot|svg|woff|woff2)$/,use: 'url-loader'},//处理字体文件
      {test:/.\js$/,use:'babel-loader',exclude:/node_modules/},
      {test:/\.vue$/,use:'vue-loader'}, //处理.vue文件的loaders
      
    ]
},
  plugins: [
    new htmlWebpackPlugin({
      template: path.join(__dirname,'./src/index.html'),
      filename: 'index.html'
    })
  ]
}